<%-- 
    Document   : profile
    Created on : 05.08.2014, 18:21:19
    Author     : Andrey
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>


<div class="containe-fluid">
    <div class="row">
        <div class="col-md-5 text-center well">
            <c:if test="${not empty user.avaPath}">
                <img src="${user.avaPath}" class="img-thumbnail" width="226" height="226"/>
            </c:if>
            <c:if test="${empty user.avaPath}">
                <img src="https://vk.com/images/camera_200.gif" class="img-thumbnail" width="226" height="226"/>
            </c:if>
            <h2>${user.userLogin}
                <small>id: ${user.userId}</small>
            </h2>
            <c:if test="${not empty user.phoneNo}">
                <address>
                    <strong>Phone No: </strong>${user.phoneNo}
                </address>

            </c:if>
            <button class="btn btn-block" onclick="messageSendStart()">Send message</button>
        </div>
        <div class="col-md-5">
            <h2>Top-7 Investitions:</h2>
            <table class="table table-striped">
                <c:forEach items="${user.moneyTransfers}" var="moneyTransfer" end="6">
                    <tr>
                        <td>
                            <a href="<c:url value="/grant/view/${moneyTransfer.grantApplication.grantId}" />">${moneyTransfer.grantApplication.grantName}</a>
                        </td>
                        <td><fmt:formatNumber value="${moneyTransfer.moneySum}" type="CURRENCY"
                                              currencySymbol="$" groupingUsed="true"/></td>
                    </tr>

                </c:forEach>
            </table>
        </div>

    </div>
    <div class="row">
        <div class="col-md-5">
            <h2>Want to help to:</h2>
            <c:forEach items="${user.likes}" var="like">
                <a href="<c:url value="/grant/view/${like.grantApplication.grantId}" />">${like.grantApplication.grantName}</a>,
            </c:forEach>
        </div>
        <div class="col-md-6">
            <h3>Total money invested: <fmt:formatNumber value="${user.totalMoneyInvested}" type="CURRENCY"
                                                        currencySymbol="$" groupingUsed="true"/></h3>

            <h3>Average investition: <fmt:formatNumber value="${user.averageInvestAmount}" type="CURRENCY"
                                                       currencySymbol="$" groupingUsed="true"/></h3>

            <h3>Wants to help the ${user.likes.size()} projects</h3>

            <h3>Apply for ${user.moneyTransfers.size()} grants</h3>

            <h3>7 Successful projects</h3>
        </div>
    </div>
</div>
</div>
<script>
    function messageSendStart() {
        $("#messageModal").modal();
    }
</script>

<div class="modal fade" id="messageModal" tabindex="-1" role="dialog" aria-labelledby="messageModalLabel"
     aria-hidden="true">
    <form class="form-horizontal" action="<c:url value="/my/message/send/${user.userId}"/>"
          METHOD="post">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span
                            class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="messageModalLabel">Send message to ${user.userLogin}</h4>
                </div>
                <div class="modal-body">
                    <div class="container-fluid">

                        <div class="form-group">
                            <textarea name="messageText"></textarea>
                        </div>

                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="submit" class="btn btn-primary">Send message</button>
                </div>
            </div>
        </div>
    </form>
</div>